using System;

namespace SharpMud.Text.Formatting.BuiltIn
{
	public class SetBackgroundColor : ISetBackgroundColor
	{
		#region Instance Stuff
		private SharpMud.Net.Telnet.ANSI.BackgroundColor _Color;

		private SetBackgroundColor()
		{
		}
		public SetBackgroundColor(SharpMud.Net.Telnet.ANSI.BackgroundColor color)
		{
			_Color = color;
		}
		#endregion

		#region Static Static Stuff
		public class Black : SetBackgroundColor
		{ public Black() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Black) {}	}

		public class Red : SetBackgroundColor
        { public Red() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Red) { } }

		public class Green : SetBackgroundColor
        { public Green() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Green) { } }

		public class Yellow : SetBackgroundColor
        { public Yellow() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Yellow) { } }

		public class Blue : SetBackgroundColor
        { public Blue() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Blue) { } }

		public class Magenta : SetBackgroundColor
        { public Magenta() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Magenta) { } }

		public class Cyan : SetBackgroundColor
        { public Cyan() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Cyan) { } }

		public class Gray : SetBackgroundColor
        { public Gray() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Gray) { } }

		public class Default : SetBackgroundColor
        { public Default() : base(SharpMud.Net.Telnet.ANSI.BackgroundColor.Default) { } }
		#endregion

		#region ISetBackgroundColor Members

        public SharpMud.Net.Telnet.ANSI.BackgroundColor Color
		{
			get
			{
				return _Color;
			}
		}

		#endregion

		#region ITextFormatEffect Members

		public string Render(SharpMud.Net.Telnet.Session.TelnetSessionBase telnetSession)
		{
			if(telnetSession.UseMXP)
			{
				return this.ToMXP();
			}
			else if(telnetSession.UseANSI)
			{
				return this.ToANSI();
			}
			else
			{
				return String.Empty;
			}
		}

		public string ToANSI()
		{
			return Net.Telnet.ANSI.Utility.SetColor(this.Color);
		}

		public string ToMXP()
		{
			return "<C BACK=" + this.Color.ToString().ToLower() + ">";
		}
		#endregion
	}
}